package coroutines.coroutine.globalscope

import kotlinx.coroutines.*
import java.lang.Exception

class GlobalScopeLaunchTest {
}

fun main() {
    val job = GlobalScope.launch (context = Dispatchers.Default){
        println("GlobalScope start0, job.isActive  = ${isActive}")

        launch {
            delay(100)
            println("launch1 completed, job.isActive  = ${isActive}")
        }

        launch {
            delay(200)
            println("launch2 completed, job.isActive  = ${isActive}")
        }

        launch {
            delay(300)
            println("launch3 completed, job.isActive  = ${isActive}")
        }

        println("GlobalScope start1, job.isActive  = ${isActive}")

        coroutineScope {  }

        CoroutineScope(Job())

        supervisorScope {

        }
    }

    try {
        Thread.sleep(1000)
    } catch (e: Exception) {
        e.printStackTrace()
    }

    println("Main thread completed, job.isActive  = ${job.isActive}")
}